package com.ymttest.database.sqlwapper;

import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.Application;
import com.ymttest.database.model.AuthCode;
import com.ymttest.utils.EnvSetup;

public class OpenApiWapper {
	SqlManager manager;

	public OpenApiWapper() {
		manager = new SqlManager("OpenApi");
	}
	
	//////////////Appplication////////////////////////
	public List<Application> selectApplicationByAppName(String appName) {
		List<Application> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.ApplicationMapper.selectApplicationByAppName",
						appName);
		return result;
	}
	
	public List<Application> selectApplicationById(String appId) {
		List<Application> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.ApplicationMapper.selectByPrimaryKey",
						appId);
		return result;
	}
	
	public List<Application> selectApplicationBySellerId(Long sellerId) {
		List<Application> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.ApplicationMapper.selectApplicationBySellerId",
						sellerId);
		return result;
	}
	
	public List<Application> selectUnauthorizeApplicationBySellerId(Long sellerId) {
		List<Application> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.ApplicationMapper.selectUnauthorizeApplicationBySellerId",
						sellerId);
		return result;
	}
	
	public List<Application> selectAuthorizeApplicationBySellerId(Long sellerId) {
		List<Application> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.ApplicationMapper.selectAuthorizeApplicationBySellerId",
						sellerId);
		return result;
	}
	
	public List<Application> selectEnableThirdPartyApplication()
	{
		List<Application> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.ApplicationMapper.selectEnableThirdPartyApplication",
						null);
		return result;
	}
	
	//////////////AuthCode////////////////////////
	public List<AuthCode> selectAuthCodeByAppId(String appId) {
		List<AuthCode> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.AuthCodeMapper.selectAuthCodeByAppId",
						appId);
		return result;
	}
	
	public List<AuthCode> selectAuthCodeById(long id) {
		List<AuthCode> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.AuthCodeMapper.selectByPrimaryKey",
						id);
		return result;
	}
	
	public static void main(String[] args) {
		System.out.println(new OpenApiWapper().selectApplicationBySellerId((long)3383).get(0).getApp_name());
	}
}
